var storage = {
  set(key, value) {
    localStorage.setItem(key, JSON.stringify(value))
  },
  get(key) {
    if (key === 'userInfo') {
      // 判断如果当前用户有没有orgList
      if (JSON.parse(localStorage.getItem(key)) !== null) {
        if (JSON.parse(localStorage.getItem(key)).orgList === null) {
          // 没有则手动添加一个orgid
          const data = JSON.parse(localStorage.getItem(key))
          data.orgList = []
          data.orgList[0] = { id: 83 }
          return JSON.stringify(data)
        } else {
          return localStorage.getItem(key)
        }
      }
    }
    return localStorage.getItem(key)
  },
  remove(key) {
    localStorage.removeItem(key)
  },
  clear() {
    localStorage.clear()
  }
}

export default storage

// var storage = {
//   set(key, value) {
//     localStorage.setItem(key, JSON.stringify(value))
//   },
//   get(key) {
//     return localStorage.getItem(key)
//   },
//   remove(key) {
//     localStorage.removeItem(key)
//   },
//   clear() {
//     localStorage.clear()
//   }
// }

// export default storage

